38 #define F_USING_MAG 0x0002 // normally should be defined in build.h 44 #define MAGBUFFSIZEX 14 45 #define MAGBUFFSIZEY (2 * MAGBUFFSIZEX)
46 #define MINMEASUREMENTS4CAL 110
47 #define MINMEASUREMENTS7CAL 220
48 #define MINMEASUREMENTS10CAL 330
49 #define MAXMEASUREMENTS 360
50 #define CAL_INTERVAL_SECS 300
51 #define MINBFITUT 10.0F
52 #define MAXBFITUT 90.0F
53 #define FITERRORAGINGSECS 86400.0F
54 #define MESHDELTACOUNTS 50
55 #define DEFAULTB 50.0F
125 #else // if F_USING_MAG 136 #endif // if F_USING_MAG 137 #endif // #ifndef MAGNETIC_H float ftrB
trial value of geomagnetic field magnitude in uT
int8_t i7ElementSolverTried
flag to denote at least one attempt made with 4 element calibration
struct MagCalibration MagCalibration
Magnetic Calibration Structure.
#define MAGBUFFSIZEX
x dimension in magnetometer buffer (12x24 equals 288 elements)
void fUpdateMagCalibration7Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
void fUpdateMagCalibration7(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
int16_t tanarray[MAGBUFFSIZEX-1]
array of tangents of (100 * angle)
void fUpdateMagCalibration4Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
void fInitializeMagCalibration(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer)
void fUpdateMagCalibration4(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
int8_t iNewCalibrationAvailable
flag denoting that a new calibration has been computed
int8_t iInitiateMagCal
flag to start a new magnetic calibration
int16_t iMagBufferCount
number of magnetometer readings
Magnetic Calibration Structure.
void fUpdateMagCalibration10Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
int8_t i4ElementSolverTried
flag to denote at least one attempt made with 4 element calibration
int32_t iValidMagCal
solver used: 0 (no calibration) or 4, 7, 10 element
float ftrFitErrorpc
trial value of fit error %
int8_t iMagBufferReadOnly
flag to denote that the magnetic measurement buffer is temporarily read only
struct MagBuffer MagBuffer
The Magnetometer Measurement Buffer holds a 3-dimensional "constellation" of data points...
float fFitErrorpc
current fit error %
int8_t iCalInProgress
flag denoting that a calibration is in progress
float fYTY
Y^T.Y for 4 element calibration = (iB^2)^2.
void fInvertMagCal(struct MagSensor *pthisMag, struct MagCalibration *pthisMagCal)
void fRunMagCalibration(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag, int32_t loopcounter)
int32_t index[MAGBUFFSIZEX][MAGBUFFSIZEY]
array of time indices
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
float fB
current geomagnetic field magnitude (uT)
The Magnetometer Measurement Buffer holds a 3-dimensional "constellation" of data points...
float fBSq
square of fB (uT^2)
#define MAGBUFFSIZEY
y dimension in magnetometer buffer (12x24 equals 288 elements)
void fUpdateMagCalibration10(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
void iUpdateMagBuffer(struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag, int32_t loopcounter)
int16_t iBs[3][MAGBUFFSIZEX][MAGBUFFSIZEY]
uncalibrated magnetometer readings
int32_t itimeslice
counter for tine slicing magnetic calibration calculations
int8_t i10ElementSolverTried
flag to denote at least one attempt made with 4 element calibration